package cn.flying.cloud.task.core.batch.listener;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.batch.core.JobParameters;
import org.springframework.batch.core.JobParametersInvalidException;
import org.springframework.batch.core.JobParametersValidator;
import org.springframework.stereotype.Component;

import cn.flying.cloud.base.common.utils.Ft;

/**
 * 批量任务参数校验
 *
 * @author: admin
 * @date: 2024年01月11日 17:21
 * @version: 1.0
 */
@Component
public class JobValidationListener implements JobParametersValidator {
    private final Logger logger = LoggerFactory.getLogger(this.getClass());

    /**
     * Check the parameters meet whatever requirements are appropriate, and
     * throw an exception if not.
     *
     * @param parameters some {@link JobParameters} (can be {@code null})
     * @throws JobParametersInvalidException if the parameters are invalid
     */
    @Override
    public void validate(JobParameters parameters) throws JobParametersInvalidException {
        logger.info("执行参数监听处理！【{}】", Ft.JSON.serializer(parameters));
    }
}